#include<stdio.h>
#include<stdlib.h>
#include<signal.h>

void errorHandler(int signal, siginfo_t *info, void *context)
{
	printf("Wohoo! Error: %d %i\n", signal, info->si_code);
	exit(0);
}

int main()
{
	int a = 0;
	int b = 0;
	int *ptr = NULL;

	struct sigaction newAction;
	newAction.sa_sigaction = errorHandler;
	sigemptyset(&newAction.sa_mask);
	newAction.sa_flags = SA_SIGINFO; //| SA_RESETHAND; //SA_RESETHAND = SA_ONESHOT

	sigaction(SIGFPE, &newAction, NULL);
	sigaction(SIGSEGV, &newAction, NULL);

	//a = a/b;
	*ptr = 5;

	printf("Hola: %d\n",a);
	
	return 0;
}
